<!DOCTYPE html>
<html>
<head>
	<title>Node.js聊天室</title>
</head>
<style type="text/css">
	input{
		border-radius: 20px
		padding-bottom: 10px;
	}
</style>
<body>
	<input type="text" id="mes"><br>
	<input type="button" value="发送" id="send">
	<script type="text/javascript" src="http://wulv5.com/js/socket.io.min.js"></script>
	<script type="text/javascript">

		var client = io.connect("/");//连接socket服务端

		var oMes = document.getElementById('mes'),
			oSend = document.getElementById('send');
		oSend.onclick = function() {
			var val = oMes.value;//获取文本框的内容
			if(!val){
				return;
			}
			oMes.value = "";
			client.send(val);//客户端向服务端发消息
			
		}
		client.on("message", function(data){
			var p = document.createElement("p");
			p.innerHTML = data;
			document.body.appendChild(p)
		})
	</script>
</body>
</html>